package com.example.interesting.idempotent.realize.aop;

import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;

import java.lang.annotation.Annotation;

/**
 * @Description: aop对应的切点
 * @Author: fyw
 * @History
 */
public class IdempotentPointcut implements Pointcut {

    private final Class<? extends Annotation> aClass;

    public IdempotentPointcut(Class<? extends Annotation> aClass) {
        this.aClass = aClass;
    }

    @Override
    public ClassFilter getClassFilter() {
        return ClassFilter.TRUE;
    }

    @Override
    public MethodMatcher getMethodMatcher() {
        return new IdempotentMethodMatcher(aClass);
    }
}
